package main

import (
	"fmt"
	"time"
)

var C chan int = make(chan int, 100)

func main() {
	go loop(C)
	time.Sleep(time.Second * 5)
	for i := 0; i < 100; i++ {
		fmt.Println("1---------------------")
		C <- i
		time.Sleep(time.Millisecond * 500)
	}
	fmt.Println("sleep")

	close(C)
	time.Sleep(time.Second * 5)
	fmt.Println("---------------------")

}

func loop(c chan int) {
	for a := range c {
		fmt.Println(a)
	}
	fmt.Println("over")
}
